import 'package:flutter/material.dart';
import '../bean/ui_const_bean.dart';

enum HomeHeadTitleIndicateType {
  HomeHeadTitleIndicateDefaultType,
  HomeHeadTitleIndicateLookAtType,
  HomeHeadTitleIndicateLookAtMoreType,
}

typedef OnItemHeadTap = void Function();

class WorkHeadWidget extends StatelessWidget {
  final String title ;
  final HomeHeadTitleIndicateType  indicateType;
  final EdgeInsets pading ;
  final double radius;
  final OnItemHeadTap itemHeadTap;

  WorkHeadWidget({
    this.title,
    this.indicateType,
    this.itemHeadTap,
    this.pading = const EdgeInsets.all(0),
    this.radius = 0,
  });

  @override
  Widget build(BuildContext context) {
    if(itemHeadTap!= null) {
      return InkWell(
          onTap: (){
            itemHeadTap();
          },
          child: _builderHeadWidget(),
      );
    }
    return _builderHeadWidget();
  }


  Widget _builderHeadWidget() {
    return  Container(
      height: pading.left > 0 ? (UIConstBean.FormHeadItemWH + 26) : UIConstBean.FormHeadItemWH,
      padding: pading,
      width: double.infinity,
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.start,
        children: <Widget>[
          Text(title,
            textAlign: TextAlign.left,
            style: TextStyle(color: Color(0xff333333),
                fontSize: 18, fontWeight: FontWeight.w600),
          ),
          const Spacer(),
          _builderIndicateWidget(),
        ],
      ),
    );
  }



  Widget _builderIndicateWidget() {
    if(indicateType == HomeHeadTitleIndicateType.HomeHeadTitleIndicateLookAtType) {
      return Text('查看',
        textAlign: TextAlign.left,
        style: TextStyle(color: Color(0xff666666), fontSize: 13,),
      );
    } else if(indicateType == HomeHeadTitleIndicateType.HomeHeadTitleIndicateLookAtMoreType) {
      return Text('更多',
        textAlign: TextAlign.left,
        style: TextStyle(color: Color(0xff666666), fontSize: 13,),
      );
    }
    return Text('点击刷新', textAlign: TextAlign.right,
        style: TextStyle(color: Color(0xff3dbcc6), fontSize:13)
    );
  }
}